<?php
namespace app\admin\controller;
use app\common\controller\AdminBase;
use think\Controller;
use think\Config;
use think\Log;
use think\Loader;
use my\Baksql;
//数据库管理
class Back extends AdminBase{
	
	
	//网站设置
	public function index(){
		   $type=input("tp");
	       $name=input("name");
		 
		 
	       $sql=new Baksql(\think\Config::get("database"));
		   // $sql=new Baksql(\think\Config::get("database"));
	       switch ($type)
	        {
	        case "backup": //备份
	          return $sql->backup();
	          break;  
	        case "dowonload": //下载
	          $sql->downloadFile($name);
	          break;  
	        case "restore": //还原
	          return $sql->restore($name);
	          break; 
	        case "del": //删除
	          return $sql->delfilename($name);
	          break;          
	        default: //获取备份文件列表
	              if($name){//返回的数据
				  	echo 1;
				  }
	            $this->assign('list',$sql->get_filelist());
		
	            return $this->fetch('index'); 
	          
	        }
	}
	
	
}
